package by.home.controller;


import javax.servlet.*;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class NoCacheFilter implements Filter {

    @Override
    public void init(FilterConfig filterConfig) {
    }

    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain) throws IOException, ServletException {

        HttpServletResponse httpServletResponse = (HttpServletResponse) response;
        httpServletResponse.setHeader("Cache-Control", "private, no-store, no-cache, must-revalidate");
        httpServletResponse.setHeader("Pragma", "no-cache");
        filterChain.doFilter(request, httpServletResponse);
    }

    @Override
    public void destroy() {
    }
}
